package iPersistence.test;

import iPersistence.io.Resources;
import iPersistence.sqlSession.SqlSession;
import iPersistence.sqlSession.SqlSessionFactory;
import iPersistence.sqlSession.SqlSessionFactoryBuilder;
import iPersistence.test.dao.UserDao;
import iPersistence.test.pojo.User;

import java.io.InputStream;

/**
 * @author Feuler
 * @since 2020/11/6
 **/

public class Main {
    public static void main(String[] args) throws Exception {
        InputStream inputStream = Resources.getResourceAsStream("sqlMapConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();

        UserDao userDao = sqlSession.getMapper(UserDao.class);
        userDao.findAll().forEach(System.out::println);

        User user = new User();
        user.setId(2);
        user.setUsername("李四");
        System.out.println(userDao.findByCondition(user));
    }
}
